package util

import (
	"fmt"
	"os"
	"os/exec"
)

func CloneSrc(dir, src string) error {
	root, err := os.Getwd()
	if err != nil {
		return err
	}
	defer os.Chdir(root)

	if err := MkDir(dir); err != nil {
		return err
	}
	err = os.Chdir(dir)
	if err != nil {
		return err
	}
	cmd := exec.Command("git", "clone", src)
	return PipeOutput(cmd, func(line []byte) {
		fmt.Println(string(line))
	})
}
